//package com.quanshi.accountmanager.controller;
//
//import com.dahantc.ctc.utils.MD5;
//import com.dahantc.sms.entity.response.template.SmsTemplateSubmitResponse;
//import com.quanshi.accountmanager.common.ReturnCode;
//import com.quanshi.accountmanager.common.StaticDataManager;
//import com.quanshi.accountmanager.domain.AmAccount;
//import com.quanshi.accountmanager.domain.AmCurrency;
//import com.quanshi.accountmanager.domain.InviteCode;
//import com.quanshi.accountmanager.domain.Req.AccountLoginReq;
//import com.quanshi.accountmanager.domain.Req.AccountRegisterReq;
//import com.quanshi.accountmanager.domain.Req.AccountVerificationReq;
//import com.quanshi.accountmanager.domain.Rsp.AccountLoginRsp;
//import com.quanshi.accountmanager.domain.Rsp.AccountVerificationRsp;
//import com.quanshi.accountmanager.domain.Vo.AccountOnlineVo;
//import com.quanshi.accountmanager.domain.Vo.AmAccountVo;
//import com.quanshi.accountmanager.domain.Vo.DataEncipher;
//import com.quanshi.accountmanager.service.IAmAccountService;
//import com.quanshi.accountmanager.service.IAmCurrencyService;
//import com.quanshi.accountmanager.service.IInviteCodeService;
//import com.quanshi.accountmanager.utils.*;
//import com.quanshi.accountmanager.utils.sms.SmsTemplateClient;
//import com.quanshi.common.annotation.Log;
//import com.quanshi.common.core.controller.BaseController;
//import com.quanshi.common.core.domain.AjaxResult;
//import com.quanshi.common.core.page.TableDataInfo;
//import com.quanshi.common.core.redis.RedisCache;
//import com.quanshi.common.enums.BusinessType;
//import com.quanshi.common.utils.StringUtils;
//import com.quanshi.common.utils.poi.ExcelUtil;
//import okhttp3.Response;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.access.prepost.PreAuthorize;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletRequest;
//import java.io.IOException;
//import java.util.*;
//import java.util.concurrent.TimeUnit;
//
///**
// * 账号信息Controller
// *
// * @author quanshi
// * @date 2023-09-21
// */
//@RestController
//public class Controller {
//
//    @Autowired
//    private IInviteCodeService inviteCodeService;
//
//    /**
//     * 查找账号是否实名认证
//     */
//    @PostMapping("/getAccountRealNameVerify")
//    public AjaxResult getAccountRealNameVerify(HttpServletRequest request, @RequestBody AmAccount amAccount) {
//        String ip = CheckUserRealIpHelper.getIpAddress(request);
//        if (!StaticDataManager.checkConnectIP(ip))
//            return AjaxResult.faild(ReturnCode.NOT_INWhiteLIST, "连接ip不在白名单内", null);
//
//        if (Objects.isNull(amAccount.getId()))
//            return AjaxResult.error("参数值为空");
//
//        AmAccount account = amAccountService.selectAmAccountById(Long.valueOf(String.valueOf(amAccount.getId())));
//        if (Objects.isNull(account))
//            return AjaxResult.error("没有找到该账号");
//        if (Objects.nonNull(account.getIdcard()) && Objects.nonNull(account.getRealname()))
//            return AjaxResult.faild(ReturnCode.Real_Name_Verify, "该账号已实名认证", false);
//        return AjaxResult.faild(ReturnCode.Real_Name_Verify_Not, "该账号未实名认证", true);
//    }
//
//
//    /**
//     * 实名验证
//     */
//    @PostMapping("/realNameVerify")
//    public AjaxResult realNameVerify(HttpServletRequest request, @RequestBody AmAccount amAccount) {
//        String ip = CheckUserRealIpHelper.getIpAddress(request);
//        if (!StaticDataManager.checkConnectIP(ip))
//            return AjaxResult.faild(ReturnCode.NOT_INWhiteLIST, "连接ip不在白名单内", null);
//
//        if (Objects.isNull(amAccount.getId()) || Objects.isNull(amAccount.getIdcard()) || Objects.isNull(amAccount.getRealname()))
//            return AjaxResult.error("参数值为空");
//
//        AmAccount account = amAccountService.selectAmAccountById(Long.valueOf(String.valueOf(amAccount.getId())));
//        if (Objects.isNull(account))
//            return AjaxResult.error("没有找到该账号");
//        if (Objects.nonNull(account.getIdcard()) && Objects.nonNull(account.getRealname()))
//            return AjaxResult.faild(ReturnCode.Real_Name_Verify, "该账号已实名认证", null);
//
//        //将身份证号和真实姓名存入 Map 中
//        Map<String, String> params = new HashMap<>();
//        params.put("idcard", AesUtil.decrypt(amAccount.getIdcard()));
//        params.put("name", AesUtil.decrypt(amAccount.getRealname()));
//
//        try {
//            //身份证验证
//            Response response = IdentityVerify.postForm(params);
//            if (Objects.isNull(response))
//                return AjaxResult.faild(ReturnCode.Not_Real_Name_Verify, "参数错误，验证失败", null);
//            int code = response.code();
//            if (code == 200) {
//                //将验证的身份信息存入数据库
//                account.setIdcard(amAccount.getIdcard());
//                account.setRealname(amAccount.getRealname());
//                amAccountService.updateAmAccount(account);
//                return AjaxResult.success("身份验证成功");
//            }
//            return AjaxResult.faild(ReturnCode.Not_Real_Name_Verify, response.message(), null);
//        } catch (IOException e) {
//            logger.info("数据处理异", e);
////            throw new RuntimeException(e);
//        }
//        return AjaxResult.success();
//    }
//
//}
